package com.mytinyRPC.register.zookeeperRegister;



import com.mytinyRPC.framework.URL;
import com.mytinyRPC.register.ServiceRegistry;

import java.net.InetSocketAddress;

public class ZkServiceRegistry  implements ServiceRegistry {
    public ZkServiceRegistry() {
    }

    //清空节点
    @Override
    public void clear(){
        CuratorUtils.clearRegistry();
    }
    //清空节点
    public static void clearOne(String path){
        CuratorUtils.clearOneRegistry(path);
    }

    @Override
    public void registerService(String interfaceName, URL inetSocketAddress) {
        //根节点下注册子节点：服务
        String servicePath = CuratorUtils.ZK_REGISTER_ROOT_PATH + "/" + interfaceName+"/"  + inetSocketAddress.toString();
        CuratorUtils.createPersistentNode(servicePath);
    }
}
